﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WorkingTime.Classes.Model
{
    public class WorkTime : NotifyPropertyChangedClass
    {
        private DateTime? startTime;
        private DateTime? stopTime;
        private TimeSpan duration;

        public DateTime? StartTime
        {
            get { return startTime; }
            set
            {
                startTime = value;
                this.OnPropertyChanged(nameof(StartTime));
            }
        }

        public DateTime? StopTime
        {
            get { return stopTime; }
            set
            {
                stopTime = value;
                this.OnPropertyChanged(nameof(StopTime));
            }
        }

        public TimeSpan Duration
        {
            get { return duration; }
            set
            {
                duration = value;
                this.OnPropertyChanged(nameof(Duration));
            }
        }

        public void SetStartTime(DateTime time)
        {
            this.StartTime = time;
        }

        public void SetStopTime(DateTime time)
        {
            this.StopTime = time;
            this.Duration = (DateTime)this.StopTime - (DateTime)this.StartTime;
        }

        public void SetStartTime()
        {
            this.StartTime = DateTime.Now;
        }

        public void SetStopTime()
        {
            this.StopTime = DateTime.Now;
            this.Duration = (DateTime)this.StopTime - (DateTime)this.StartTime;
        }
    }
}
